﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Algobox.Objects.Finance
{
    public static class Markets
    {
        public static bool TryGetMarketMICbyUMTF(string umtf, out MarketMIC marketMIC)
        {
            if (umtf == null
                || umtf == String.Empty
                || umtf.Length < 2)
            {
                marketMIC = MarketMIC.XXXX;
                return false;
            }

            switch (umtf[umtf.Length - 1])
            {
                case 'l':
                    marketMIC = MarketMIC.XLON;
                    return true;
                case 'a':
                    marketMIC = MarketMIC.XAMS;
                    return true;
                case 'p':
                    marketMIC = MarketMIC.XPAR;
                    return true;
                case 'm':
                    marketMIC = MarketMIC.XMIL;
                    return true;
                case 'z':
                    marketMIC = MarketMIC.XSWX;
                    return true;
                case 'b':
                    marketMIC = MarketMIC.XBRU;
                    return true;
                case 'x':
                    marketMIC = MarketMIC.XLUX;
                    return true;
                case 'u':
                    marketMIC = MarketMIC.XLIS;
                    return true;
                case 'r':
                    marketMIC = MarketMIC.XICE;
                    return true;
                case 's':
                    marketMIC = MarketMIC.XSTO;
                    return true;
                case 'o':
                    marketMIC = MarketMIC.XOSL;
                    return true;
                case 'c':
                    marketMIC = MarketMIC.XCSE;
                    return true;
                case 'e':
                    marketMIC = MarketMIC.XMCE;
                    return true;
                case 'h':
                    marketMIC = MarketMIC.XHEL;
                    return true;
                case 'd':
                    marketMIC = MarketMIC.XETR;
                    return true;
                case 'v':
                    marketMIC = MarketMIC.WBAH;
                    return true;
                case 'i':
                    marketMIC = MarketMIC.XDUB;
                    return true;
                default:
                    marketMIC = MarketMIC.XXXX;
                    return false;
            }
        }



        /// <summary>
        /// Markets of listing
        /// </summary>
        public enum MarketMIC
        {
            /// <summary>
            /// No valid market
            /// </summary>
            XXXX,
            /// <summary>
            /// London
            /// </summary>
            XLON,
            /// <summary>
            /// Paris
            /// </summary>
            XPAR,
            /// <summary>
            /// Amsterdam
            /// </summary>
            XAMS,
            /// <summary>
            /// Luxumberg
            /// </summary>
            XLUX,
            /// <summary>
            /// Milan (MTA)
            /// </summary>
            XMIL,
            /// <summary>
            /// Frankfurt
            /// </summary>
            XETR,
            /// <summary>
            /// Copenhagen
            /// </summary>
            XCSE,
            /// <summary>
            /// Brussles
            /// </summary>
            XBRU,
            /// <summary>
            /// Lisbon
            /// </summary>
            XLIS,
            /// <summary>
            /// Helsinki
            /// </summary>
            XHEL,
            /// <summary>
            /// Oslo
            /// </summary>
            XOSL,
            /// <summary>
            /// Madrid
            /// </summary>
            XMCE,
            /// <summary>
            /// Stockholm
            /// </summary>
            XSTO,
            /// <summary>
            /// Warsaw Boerse 
            /// </summary>
            WBAH,
            /// <summary>
            /// Swiss
            /// </summary>
            XSWX,
            /// <summary>
            /// Warsaw Boerse
            /// </summary>
            XWAR,
            /// <summary>
            /// Iceland
            /// </summary>
            XICE,
            /// <summary>
            /// Irish
            /// </summary>
            XDUB,
            /// <summary>
            /// Prague
            /// </summary>
            XPRA,
            /// <summary>
            /// Nasdaq
            /// </summary>
            XNAS,
            /// <summary>
            /// New York Stock Exchange
            /// </summary>
            XNYS,
            /// <summary>
            /// Amex - NYSE Alternext
            /// </summary>
            XASE,
            /// <summary>
            /// NYSE Arca
            /// </summary>
            ARCX            
        }
    }
}
